package com.example.kjn.myapplication.modle;

import android.util.SparseArray;

import com.example.kjn.myapplication.bean.UserBean;

/**
 * <pre>
 *     author : kjn
 *     e-mail : xxx@xx
 *     time   : 2017/12/05
 *     desc   :
 * </pre>
 */
public class ModleUser implements IModleUser {


    private SparseArray<UserBean> uersBeanSparseArray;

    @Override
    public void save(int id, String name, String password) {
        if (uersBeanSparseArray == null) {
            uersBeanSparseArray = new SparseArray<>();
        }
        uersBeanSparseArray.put(id, new UserBean(name, password));
    }

    @Override
    public UserBean load(int id) {
        if (uersBeanSparseArray != null && uersBeanSparseArray.size() > 0) {
            return uersBeanSparseArray.get(id);
        }
        return null;
    }
}
